#pragma once
#include "shader.hpp"

class particle_shader : public shader {
private:
	GLuint _matloc;
	GLuint _curtimeloc;
	GLuint _samplerloc;
	
public:
	bool
	init(const char *vertexfile, const char *fragmentfile) {
		if (!linkprogram(vertexfile, fragmentfile))
			return false;
		_matloc = glGetUniformLocation(_program, "u_matrix");
		_curtimeloc = glGetUniformLocation(_program, "u_curtime");
		_samplerloc = glGetUniformLocation(_program, "u_sampler");
		return true;
	}

	void
	setuniform(const glm::mat4 &matrix, float curtime, GLuint texid) {
		glUniformMatrix4fv(_matloc, 1, GL_FALSE, glm::value_ptr(matrix));
		glUniform1f(_curtimeloc, curtime);

		glActiveTexture(GL_TEXTURE0);
		glBindTexture(GL_TEXTURE_2D, texid);
		glUniform1i(_samplerloc, 0);
	}
};